package cn.yunbamboos.media.hook.in;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;

import java.util.Optional;

public class GenericHookInDTO {

    protected JSONObject body;

    protected String mediaServerId;

    public GenericHookInDTO(String body){
        if(StrUtil.isNotBlank(body)){
            this.body = JSONObject.parse(body);
        } else {
            this.body = new JSONObject();
        }
        this.decode();
    }

    public void decode(){
        this.mediaServerId = this.body.getString("mediaServerId");
    }

    public Optional<String> getMediaServerId() {
        return Optional.ofNullable(mediaServerId);
    }

}
